using UnityEngine;

public class ItemShop : MonoBehaviour
{
	public ItemData[] Items;

	private void Start()
	{
	}

	public void Buy(ItemData item)
	{
		if (!(UnitZ.playerManager.PlayingCharacter == null))
		{
			UnitZ.playerManager.PlayingCharacter.inventory.AddItemByItemData(item, 1, -1, -1);
		}
	}

	private void OnGUI()
	{
		for (int i = 0; i < Items.Length; i++)
		{
			GUI.DrawTexture(new Rect(10f, 80 * i, 50f, 50f), Items[i].ImageSprite.texture);
			GUI.Label(new Rect(80f, 80 * i, 200f, 50f), Items[i].ItemName);
			if (GUI.Button(new Rect(400f, 80 * i, 100f, 50f), "Buy"))
			{
				Buy(Items[i]);
			}
		}
	}
}
